// main store
import Vue from 'vue';
import Vuex from 'vuex';
import { getLocal } from '~/service/local';

Vue.use(Vuex);

const store = new Vuex.Store({
  state: {
    count: 0,
    data: null
  },
  mutations: {
    increment (state) {
      state.count++;
    },
    setData (state, data) {
      state.data = data;
    }
  },
  actions: {
    modelCount ({commit}) {
      commit('increment');
    },
    getLocal ({commit}, payload) {
      console.log('request params', payload);
      getLocal(payload).then((value) => {
        console.log('store getLocal', value);
        commit('setData', value);
      });
    }
  }
})

export default store;